package com.employeemanage.domain.resp;

import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * ClassName: Result
 * Package: com.auth.userservice.domain.resp
 * Description:
 * Author by: HUANG
 * Created by: 2025/6/13 10:46
 * Version 1.0
 */
@Data
@NoArgsConstructor
@Getter
@Setter
public class Result<T> {
    private Boolean success;
    private String errorMsg;
    private T data;
    private int code;

    public Result(Boolean success, String errorMsg, T data, int code) {
        this.success = success;
        this.errorMsg = errorMsg;
        this.data = data;
        this.code = code;
    }
    public static <T> Result<T> success() {
        return new Result<>(true, null, null,200);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(true, null, data,200);
    }

    public static <T> Result<List<T>> success(List<T> data, Long total) {
        return new Result<>(true, null, data,200);
    }

    public static <T> Result<T> fail(String errorMsg) {
        return new Result<>(false, errorMsg, null,-100);
    }

    public static <T> Result<T> fail(String errorMsg,int code) {
        return new Result<>(false, errorMsg, null,code);
    }
}

